import Taro from '@tarojs/taro-rn';
import * as tslib_1 from "tslib";
import React from 'react';
import { Component } from "@tarojs/taro-rn";
import { View, Image, Text } from "@tarojs/components-rn";
import { toJS } from 'mobx';
import { inject, observer } from "@tarojs/mobx-rn";
import { getRuntime, pageSize, servicePhoneNumber } from "../../utils/common";
import helpStyleSheet from "./help_styles";
import right from "../../assets/img/right.png";
var _styleSheet = helpStyleSheet;
let Personnel = class Personnel extends Component {
  constructor(props) {
    super(props);
    this.state = {
      pageIndex: 1,
      pageSize,
      items: []
    };
  }
  componentWillMount() {
    Taro.setNavigationBarTitle({ title: '帮助中心' });
    this.getDoubtAnswers();
  }
  handelRouter(url = '/pages/index/index') {
    getRuntime().navigateTo(url);
  }
  getDoubtAnswers() {
    let { userStore } = this.props.stores;
    userStore.getDoubtAnswers({
      callback: res => {
        this.setState({ items: toJS(res.items) });
      }
    });
  }
  makePhone() {
    getRuntime().makePhoneCall(servicePhoneNumber);
  }
  render() {
    let { items } = this.state;
    return <View style={_styleSheet["my-help"]}>
        {items.length > 0 && <View style={_styleSheet["help-item"]}>
          {items.map(item => {
          return <View onClick={this.handelRouter.bind(this, '/pages/user/help_detail?id=' + item.id)} style={_styleSheet["item"]}>
                  <View style={_styleSheet["list-title"]}>{item.title}</View>
                  <Image src={right} style={_styleSheet["icon-drop-down"]} />
                </View>;
        })}
        </View>}

        {items.length <= 0 && <View style={_styleSheet["page-none-info"]}>
           <Text style={[_styleSheet["none-title"], _styleSheet["list-desc"]]}>信息收集中...</Text>
        </View>}

        <View onClick={this.makePhone.bind(this)} style={_styleSheet["page-submit"]}>联系客服：{servicePhoneNumber}</View>
      </View>;
  }
};
Personnel = tslib_1.__decorate([inject("stores"), observer], Personnel);
export default Personnel;